<?php
class ControllerExtensionModuleCarousel extends Controller {
    /**
     * 热门品牌
     *
     * @param $setting
     *
     * @return string
     * @throws Exception
     */
    public function index($setting) {
        static $module = 0;

        $this->load->model('design/banner');
        $this->load->model('tool/image');

        $this->document->addStyle('catalog/view/javascript/jquery/swiper/css/swiper.min.css');
        $this->document->addScript('catalog/view/javascript/jquery/swiper/js/swiper.min.js');

        $data['banners'] = array();

        $this->load->language('extension/module/carousel');

        $results = $this->model_design_banner->getBanner($setting['banner_id']);

        foreach ($results as $result) {
            $data['banners'][] = array(
                'title' => $result['title'],
                'link'  => $result['link'],
                'image' => $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height'])
            );
        }

        $data['module'] = $module++;

        return $this->load->view('extension/module/carousel', $data);
    }
}